#include <iostream>
using namespace std;

/*
class A {
public:
    ~A() {
        cout << "~A()";
    }
};

class B{
public:
    virtual ~B() {
        cout << "~B()";
    } }
;

class C: public A, public B {
public:
    ~C() {
        cout << "~C()";
    }
};


void test1() {
    C * c = new C;
    B * b1 = dynamic_cast<B *>(c);
    A * a2 = dynamic_cast<A *>(b1);

    delete a2;
}
*/

class A
{
public:
    A ():m_iVal(0){
        test();
    }
    virtual void func() {
        std::cout<<m_iVal<<' ';
    }
    void test(){
        func();
    }
public:
    int m_iVal;
};

class B : public A
{
public:
    B(){
        test();
    }
    virtual void func()
    {
        ++m_iVal;
        std::cout<<m_iVal<<' ';
    }
};

void test2()
{
    A* p = new B;
    p->test();
}


int main() {
    test2();
    return 0;
}
